package com.mayisoftware.mayioa.business.staff.impl.controller;


import com.mayisoftware.mayioa.business.staff.api.domain.StaffInfo;
import com.mayisoftware.mayioa.business.staff.api.domain.StaffSearchInfo;
import com.mayisoftware.mayioa.business.staff.api.service.IStaffViewService;
import com.mayisoftware.mayioa.platform.impl.web.base.BaseController;
import com.mayisoftware.mayioa.platform.impl.web.page.TableDataInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/staff/list")
public class StaffViewController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(StaffViewController.class);
    private String prefix = "staff/list";

    @Autowired
    private IStaffViewService svService;


    @RequiresPermissions("staff:list:view")
    @GetMapping()
    public String staff() {
        return prefix + "/list";
    }

    @RequiresPermissions("staff:list:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StaffSearchInfo searchInfo) {
        startPage();
        List<StaffInfo> list = svService.getStaffInfos(searchInfo);
        return getDataTable(list);
    }

}